package ee.ut.aa.neuraltic.model;

import java.util.List;
import java.util.Random;

import org.apache.log4j.Logger;

public class RandomPlayer implements Player {

	private static Logger log = Logger.getLogger( RandomPlayer.class );

	private Random r;
	private int value;

	public RandomPlayer( int value ) {

		this.value = value;
		this.r = new Random();
	}

	@Override
	public Board makeNextMove( Board board ) {

		log.debug( "Requesting next move for player " + value );

		List<Integer> legalMoves = board.getLegalMoves();

		int random = r.nextInt( legalMoves.size() );

		int move = legalMoves.get( random );

		log.debug( "Next move is: " + move );

		board.makeMove( move );

		return board;
	}

	@Override
	public int getValue() {

		return value;
	}

	@Override
	public void setValue( int value ) {

		this.value = value;
	}
}
